package easy;

public class Solution_1128 {

    public int numEquivDominoPairs(int[][] dominoes) {
        int[][] arr = new int[10][10];
        for (int[] dominoe : dominoes) {
            arr[dominoe[0]][dominoe[1]]++;
            if (dominoe[0] != dominoe[1]) {
                arr[dominoe[1]][dominoe[0]]++;
            }
        }
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j <= i; j++) {
                if (arr[i][j] > 1) {
                    count = count + arr[i][j] * (arr[i][j] - 1) / 2;
                }
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Solution_1128 model = new Solution_1128();
        System.out.println(model.numEquivDominoPairs(new int[][]{{1, 2}, {2, 1}, {3, 4}, {5, 6}}));
    }
}
